home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-23 | 2.2 KB | 100 lines | [TEXT/PJMM] |
- unit MenuStuff;
- interface
- procedure HandleMenuChoice (menuChoice: LONGINT);
- procedure GetNewPreferences;
- implementation
- uses
- Strings, Globals;
-
- const
-
- ABOUT_ITEM = 1;
- APPLE_MENU_ID = 400;
- FILE_MENU_ID = APPLE_MENU_ID + 1;
- EDIT_MENU_ID = APPLE_MENU_ID + 2;
- CLOCK_MENU_ID = APPLE_MENU_ID + 3;
-
- procedure HandleAppleChoice (theItem: INTEGER);
- var
- accName: Str255;
- accNumber, itemNumber, dummy: INTEGER;
- appleMenu: MenuHandle;
- begin
-
- case theItem of
- ABOUT_ITEM:
- dummy := Alert(400, nil);
-
- otherwise
- begin
- appleMenu := GetMHandle(APPLE_MENU_ID);
- GetItem(appleMenu, theItem, accName);
- accNumber := OpenDeskAcc(accName);
- end;
- end;
- end;
- { if we have a copy command, stick the current date into the clipboard }
- procedure HandleCopyItem;
- var
- dateString, timeString, spaceString: Str255;
- time: LONGINT;
- length: integer;
- cPtr: Ptr;
- pString: StringPtr;
- lErr: LONGINT;
- dForm: DateForm;
- begin
- GetDateTime(time);
- IUTimeString(time, FALSE, timeString);
- dForm := DateForm(1);
- IUDateString(time, dForm, dateString);
- spaceString := ', ';
- dateString := Concat(dateString, spaceString);
- dateString := Concat(dateString, timeString);
- length := Ord(dateString[0]);
- pString := @dateString;
- cPtr := P2CStr(pString);
- lErr := ZeroScrap;
- lErr := PutScrap(length, 'TEXT', cPtr);
- end;
-
- procedure HandleMenuChoice (menuChoice: LONGINT);
- var
- theMenu, theItem: INTEGER;
- aMenuHandle: MenuHandle;
- begin
- if menuChoice <> 0 then
- begin
- theMenu := HiWord(menuChoice);
- theItem := LoWord(menuChoice);
- case theMenu of
- APPLE_MENU_ID:
- HandleAppleChoice(theItem);
- FILE_MENU_ID:
- begin
- if theItem = 1 then
- gDone := TRUE;
- end;
- EDIT_MENU_ID:
- begin
- if theItem = 4 then
- begin
- HandleCopyItem;
- end;
- end;
- CLOCK_MENU_ID:
- begin
- HiliteMenu(0);
- aMenuHandle := GetMHandle(CLOCK_MENU_ID);
- DisableItem(aMenuHandle, 0);
- DrawMenuBar;
- GetNewPreferences;
- if gSpeechAvailable then
- EnableItem(aMenuHandle, 0);
- DrawMenuBar;
- end;
- end;
- HiliteMenu(0);
- end;
- end;
- end.